package cn.supermaster.management.web.controller.system;

import cn.supermaster.management.web.service.system.ISDictionaryService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * All rights Reserved, Designed By www.super-bytecode.com
 *
 * @ProjectName: supermaster-management
 * @Package: cn.supermaster.management.web.controller.system
 * @ClassName: SystemDictionaryController
 * @Description: [系统字典服务controller]
 * <p> 包含dictionary_data和dictionary_type</p>
 * @Author: [Lance Ting]
 * @Date: 2021/2/20 11:06
 * @Version: V1.0
 * @Copyright: 2021 www.super-bytecode.com Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
@Controller
@RequestMapping("/system/dict")
public class SystemDictionaryController {

    @Autowired
    private ISDictionaryService dictionaryService;

    //===================================================
    // dictionary_type
    //===================================================

    @RequiresPermissions("system:dict:view")
    @GetMapping()
    public String skipDictionaryTypeIndexHtml() {
        return dictionaryService.skipDictionaryTypeIndexHtml();
    }

    /**
     * 新增字典类型
     */
    @GetMapping("/add")
    public String add() {
        return dictionaryService.skipDictionaryTypeAddHtml();
    }

    /**
     * 修改字典类型
     */
    @GetMapping("/edit/{dictId}")
    public String edit(@PathVariable("dictId") Long dictId, ModelMap modelMap) {
        return dictionaryService.skipDictionaryTypeModifyHtml(modelMap, dictId);
    }

    /**
     * 查询字典详细
     */
    @RequiresPermissions("system:dict:list")
    @GetMapping("/detail/{dictId}")
    public String skipDictionaryTypeDetailHtml(@PathVariable("dictId") Long dictId, ModelMap modelMap) {
        return dictionaryService.skipDictionaryTypeDetailHtml(modelMap, dictId);
    }

    /**
     * 选择字典树
     */
    @GetMapping("/selectDictTree/{columnId}/{dictType}")
    public String skipDictionaryTreeHtml(@PathVariable("columnId") Long columnId, @PathVariable("dictType") String dictType,
                                         ModelMap modelMap) {
        return dictionaryService.skipDictionaryTreeHtml(modelMap, columnId, dictType);
    }

    //===================================================
    // dictionary_data
    //===================================================

    @RequiresPermissions("system:dict:view")
    @GetMapping("/data")
    public String skipDictionaryDataIndexHtml() {
        return dictionaryService.skipDictionaryDataIndexHtml();
    }

    /**
     * 新增字典类型
     */
    @GetMapping("/data/add/{dictType}")
    public String skipDictionaryDataAddHtml(@PathVariable("dictType") String dictType, ModelMap modelMap) {
        return dictionaryService.skipDictionaryDataAddHtml(modelMap, dictType);
    }

    /**
     * 修改字典类型
     */
    @GetMapping("/data/edit/{dictCode}")
    public String skipDictionaryDataModifyHtml(@PathVariable("dictCode") Long dictCode, ModelMap modelMap) {
        return dictionaryService.skipDictionaryDataModifyHtml(modelMap, dictCode);
    }
}